﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Mimoza.GUI;

namespace Mimoza.CitrixPlugin
{
    public partial class ProgramsPage : Mimoza.GUI.WizardPage
    {
        public ProgramsPage()
        {
            InitializeComponent();
        }

        override public void Init()
        {
            CitrixData data = this.Wizard.UserData as CitrixData;

            checkBoxStartProgram.Checked = data.StartProgram.IsStartEnabled;
            textBoxProgramPath.Text = data.StartProgram.ProgramPath;
            textBoxProgramFolder.Text = data.StartProgram.ProgramFolder;

            this.IsConfigured = true;

            this.checkBoxStartProgram.CheckedChanged += new System.EventHandler(this.checkBoxStartProgram_CheckedChanged);
            this.textBoxProgramFolder.TextChanged += new System.EventHandler(this.textBoxProgramFolder_TextChanged);
            this.textBoxProgramPath.TextChanged += new System.EventHandler(this.textBoxProgramPath_TextChanged);
        }

        override public bool Try2LeavePage(WizardPageLeavingDirection direction)
        {
            CitrixData data = this.Wizard.UserData as CitrixData;

            data.StartProgram.IsStartEnabled = checkBoxStartProgram.Checked;
            data.StartProgram.ProgramPath = textBoxProgramPath.Text;
            data.StartProgram.ProgramFolder = textBoxProgramFolder.Text;
         
            return true;
        }

        private void checkBoxStartProgram_CheckedChanged(object sender, EventArgs e)
        {
            labelProgramFolder.Enabled = checkBoxStartProgram.Checked;
            labelProgramPath.Enabled = checkBoxStartProgram.Checked;
            textBoxProgramPath.Enabled = checkBoxStartProgram.Checked;
            textBoxProgramFolder.Enabled = checkBoxStartProgram.Checked;

            this.RaiseOnPageModified();
        }

        private void textBoxProgramPath_TextChanged(object sender, EventArgs e)
        {
            this.RaiseOnPageModified();
        }

        private void textBoxProgramFolder_TextChanged(object sender, EventArgs e)
        {
            this.RaiseOnPageModified();
        }
    }
}
